:)
-
-
Save VictorieeMan/b9e27483e6dfcbc39df54ebcabd8675c to your computer and use it in GitHub Desktop.
[package] | |
name = "sha" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
crypto-hash = "0.3.4" |
Copyright 2023 @VictorieeMan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//Created: 2023-09-11 by @VictorieeMan under the MIT license | |
extern crate crypto_hash; | |
use crypto_hash::{Algorithm, hex_digest}; | |
fn main() { | |
// Define the fixed part of the string | |
let mut string = "".to_string(); | |
let str_start = "This one is also pretty cool. The SHA256 of this X-post begins with \"420\" and ends with \"69\". PS. I use this iteration number: "; | |
//Place for sha prefix | |
let str_mid = "";//"\" and ends with \"69\", this took \""; | |
//Place for it counter | |
let str_end = " to alternate the string while \"mining\" for a specified hash code output. See my code over at https://gist.github.com/VictorieeMan/b9e27483e6dfcbc39df54ebcabd8675c 😉"; | |
// Initialize the special prefix, hash, and counter | |
let sha_prefix = "420"; | |
let sha_suffix = "69"; | |
let mut hash = String::new(); | |
let mut counter = 0; | |
// Loop until the hash starts with the special prefix | |
while !(hash.starts_with(sha_prefix) && hash.ends_with(sha_suffix)) { | |
// Construct the string for the current iteration | |
// string = format!("{}{}{}{}{}", str_start, sha_prefix, str_mid, counter.to_string(), str_end); | |
string = format!("{}{}{}", str_start, counter.to_string(), str_end); | |
// println!("str: {}", string); | |
// Calculate the hash | |
hash = hex_digest(Algorithm::SHA256, string.as_bytes()); | |
// Print the hash and the modified string with the message | |
// println!( | |
// "Hash: {} - {}",hash,string | |
// ); | |
counter += 1; | |
if(counter % 100000 == 1){ | |
println!( | |
"Hash: {} - {}",hash,string | |
); | |
} | |
} | |
// // Print the hash and the modified string with the message | |
// println!( | |
// "Hash: {} - {}", | |
// hash, | |
// format!( | |
// "{}{}, it had to be iterated {} number of times in my program.", | |
// fixed_part, special_prefix, counter | |
// ) | |
// ); | |
println!( | |
"Hash: {} - {}",hash,string | |
); | |
println!("Found a hash with the special prefix: {}", hash); | |
} | |
/* | |
MIT-license | |
Copyright 2023 @VictorieeMan | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
*/ |