Diogenes #3
|
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
public class CryptoRandom : RandomNumberGenerator
|
public class CryptoRandom : RandomNumberGenerator
|
||||||
|
|
@ -19,6 +20,19 @@ public class CryptoRandom : RandomNumberGenerator
|
||||||
r = RandomNumberGenerator.Create();
|
r = RandomNumberGenerator.Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string DiogenesCrypt(string word)
|
||||||
|
{
|
||||||
|
StringBuilder result = new StringBuilder("");
|
||||||
|
byte[] bytes = Encoding.ASCII.GetBytes(word);
|
||||||
|
|
||||||
|
foreach (byte singular in bytes)
|
||||||
|
{
|
||||||
|
result.Append(Convert.ToChar(0x55 ^ singular));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
///<param name=”buffer”>An array of bytes to contain random numbers.</param>
|
///<param name=”buffer”>An array of bytes to contain random numbers.</param>
|
||||||
public override void GetBytes(byte[] buffer)
|
public override void GetBytes(byte[] buffer)
|
||||||
{
|
{
|
||||||
|
|
@ -52,4 +66,4 @@ public class CryptoRandom : RandomNumberGenerator
|
||||||
{
|
{
|
||||||
return Next(0, maxValue);
|
return Next(0, maxValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue