|
2 | 2 |
|
3 | 3 | using SafeCrypt.AESDecryption; |
4 | 4 | using SafeCrypt.AESEncryption; |
5 | | -using SafeCrypt.Helpers; |
6 | 5 | using SafeCrypt.Models; |
7 | | -using SafeCrypt.RsaEncryption; |
8 | | -using SafeCrypt.RsaEncryption.Models; |
9 | 6 |
|
10 | 7 | var dataToEncrypt = "Data to Encrypt"; |
11 | 8 | var secret = "hghjuytsdfraestwsgtere=="; |
|
39 | 36 | Console.WriteLine($"IV key: {decryptionData.Iv}"); |
40 | 37 | Console.WriteLine($"Secret key: {decryptionData.SecretKey}"); |
41 | 38 |
|
42 | | - |
43 | | - |
44 | | -/////////////////////////// |
45 | | -/// |
46 | | -// Example: Generate RSA keys |
47 | | -var rsaKeyPair = KeyGenerators.GenerateRsaKeys(2048); |
48 | | -string rsaPublicKey = rsaKeyPair.Item1; |
49 | | -string rsaPrivateKey = rsaKeyPair.Item2; |
50 | | - |
51 | | -Console.WriteLine($"pubic key {rsaPublicKey}"); |
52 | | -Console.WriteLine($"private key {rsaPrivateKey}"); |
53 | | - |
54 | | -// Example: Encrypt and Decrypt using RSA |
55 | | -string originalData = "Hello, RSA Encryption!"; |
56 | | - |
57 | | -var enModel = new RsaEncryptionParameters |
58 | | -{ |
59 | | - DataToEncrypt = originalData, |
60 | | - PublicKey = rsaPublicKey, |
61 | | -}; |
62 | | - |
63 | | -var encryptedData = await Rsa.EncryptAsync(enModel); |
64 | | - |
65 | | -var uccRYTED = new RsaDecryptionParameters |
66 | | -{ |
67 | | - DataToDecrypt = encryptedData.EncryptedData, |
68 | | - PrivateKey = rsaPrivateKey |
69 | | -}; |
70 | | - |
71 | | -var decryptedData = await Rsa.DecryptAsync(uccRYTED); |
72 | | - |
73 | | -// Display results |
74 | | -Console.WriteLine($"Original Data: {originalData}"); |
75 | | -Console.WriteLine($"Encrypted Data: {encryptedData.EncryptedData}"); |
76 | | -//Console.WriteLine($"Encrypted Data-------: {BitConverter.ToString(encryptedData.EncryptedData)}"); |
77 | | -Console.WriteLine($"Decrypted Data: {decryptedData.DecryptedData}"); |
78 | | - |
79 | | - |
80 | | -Console.WriteLine("Hello, World!"); |
| 39 | +Console.ReadLine(); |
0 commit comments