Created
August 11, 2023 18:28
-
-
Save harsh-2024/694f219042a80e09ccb5c0cebc9b906a to your computer and use it in GitHub Desktop.
Encryption handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
final plainText = 'laiba123@A'; | |
final key = Key.fromUtf8('kf;WtH}yb/zTo!H=9}DIoS?2{_V&b/md'); | |
final iv = IV.fromLength(16); | |
final encrypter = Encrypter(AES(key, mode: AESMode.ecb)); | |
final encrypted = encrypter.encrypt(plainText, iv: iv); | |
final decrypted = encrypter.decrypt(encrypted, iv: iv); | |
print(decrypted); | |
print(encrypted.base64); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CryptoJS = require('crypto-js'); | |
const plainText = 'laiba123@A'; | |
const key = CryptoJS.enc.Utf8.parse('kf;WtH}yb/zTo!H=9}DIoS?2{_V&b/md'); | |
const iv = CryptoJS.lib.WordArray.random(16); | |
const cipherParams = CryptoJS.AES.encrypt(plainText, key, { | |
iv: iv, | |
mode: CryptoJS.mode.ECB, | |
padding: CryptoJS.pad.Pkcs7, | |
}); | |
const encryptedText = cipherParams.toString(); | |
console.log('Encrypted: ' + encryptedText); | |
const decryptedBytes = CryptoJS.AES.decrypt(cipherParams, key, { | |
iv: iv, | |
mode: CryptoJS.mode.ECB, | |
padding: CryptoJS.pad.Pkcs7, | |
}); | |
const decryptedText = decryptedBytes.toString(CryptoJS.enc.Utf8); | |
console.log('Decrypted: ' + decryptedText); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import secrets | |
import string | |
def generate_random_string(length): | |
characters = string.ascii_letters + string.digits + string.punctuation | |
random_string = ''.join(secrets.choice(characters) for _ in range(length)) | |
return random_string | |
random_string = generate_random_string(32) | |
print(random_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment