Used a more updated Base64 Encode and Decode method
This commit is contained in:
parent
af2b33f197
commit
69cfd0c91f
1 changed files with 3 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
// Libraries
|
||||
use ring::rand::{SecureRandom, SystemRandom};
|
||||
use base64::prelude::*;
|
||||
|
||||
// Constants
|
||||
|
||||
|
@ -23,11 +24,11 @@ impl Secure {
|
|||
ciphertext[i] = value_bytes[i] ^ key_bytes[i % key_bytes.len()];
|
||||
}
|
||||
|
||||
return base64::encode(ciphertext);
|
||||
return BASE64_STANDARD.encode(ciphertext);
|
||||
}
|
||||
// Takes in cyphertext and a key to decrypt it
|
||||
pub fn decrypt(cyphertext: String, key: String) -> String {
|
||||
let cyphertext_bytes = base64::decode(cyphertext).expect("(0) Decryption Failed");
|
||||
let cyphertext_bytes = BASE64_STANDARD.decode(cyphertext).expect("(0) Decryption Failed");
|
||||
let key_bytes = key.as_bytes();
|
||||
|
||||
let mut plaintext = vec![0u8; cyphertext_bytes.len()];
|
||||
|
|
Loading…
Reference in a new issue