Computing desk | ||
---|---|---|
< July 14 | << Jun | July | Aug >> | July 16 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
While I was napping, the netbook disappeared from the market. I'm looking to replace a Toshiba NB505 with something similar--small, light, (almost) full keyboard, not hot on the family jewels. Anyone have any suggestions? Thanks! Drmies (talk) 15:28, 15 July 2015 (UTC)
Some companies offer "proof of existence" services, and claim that they use blockchain authentication to timestamp documents. As I understand, this is the same technology used to bitcoin. From a technical perspective, is this a 100% sure-fire way of authenticating documents? And, from a legal perspective, do courts recognize this 100% sure-fire (if at all) way of authenticating documents?--Yppieyei (talk) 15:46, 15 July 2015 (UTC)
Hello everyone. I am trying to encrypt a string of text. I have been successful at encrypting text, but I can't seem to decrypt it. So I did a little research and found that I need to use a Public key encryption algorithm. Therefore, I came to the RSA algorithm. the .NET Framework has a class for implementing RSA. What I want to know is, who do I use the System.Security.Cryptography.RSA class? I know how to convert text into an array of bytes but I don't know how to use the RSA class. If there are any simpler methods to do what I want to do then please let me know. Thanks for your help in advance. —SGA314 I am not available on weekends (talk) 15:59, 15 July 2015 (UTC)
Long code
|
---|
//this.EncryptedText = a byte array that contains the encrypted text in bytes.
//OutputBox = a Mutli-line textbox that displays the encrypted text.
using System.Security.Cryptography;
public Aes cry = System.Security.Cryptography.AesManaged.Create();
private void Decrypt()
{
ICryptoTransform DeCrypt = cry.CreateDecryptor(this.Key, this.IV);
byte Bit = byte.Parse("0");
#region Pad Data To A 16-bit Block
int Length = this.EncryptedText.Length;
if (Mod(this.EncryptedText.Length, 16) != 0)
{
while (Mod(Length, 16) != 0)
{
Length += 1;
}
}
byte[] Input = (byte[])Array.CreateInstance(Bit.GetType(), Length);
for (int i = 0; i < this.EncryptedText.Length; i++)
{
Input[i] = this.EncryptedText[i];
}
#endregion
byte[] Output2 = DeCrypt.TransformFinalBlock(Input, 0, Input.Length);
DataBox.Text = ConvertBytesToString(Output2);
}
private int Mod(int x, int y)
{
return x - (x / y) * y;
}
private byte[] getChars()
{
ICryptoTransform Crypt = cry.CreateEncryptor(cry.Key, cry.IV);
byte Bit = byte.Parse("0");
char[] Chars = InputBox.Text.ToCharArray();
int Length = 0;
if (Mod(Chars.Count(), Crypt.OutputBlockSize) == 0)
{
Length = Chars.Count();
}
else
{
int a = Mod(16, 16);
int L = Chars.Count();
while (Mod(L, Crypt.OutputBlockSize) != 0)
{
L += 1;
}
Length = L;
}
byte[] Input = (byte[])Array.CreateInstance(Bit.GetType(), Length);
for (int i = 0; i < Chars.Count(); i++)
{
Input[i] = (byte)Chars[i];
}
return Input;
}
private void Encrypt()
{
//Generate a Random Key.
cry.GenerateKey();
cry.GenerateIV();
this.Key = cry.Key;
this.IV = cry.IV;
ICryptoTransform Crypt = cry.CreateEncryptor(cry.Key, cry.IV);
byte Bit = byte.Parse("0");
char[] Chars = InputBox.Text.ToCharArray();
int Length = 0;
if (Mod(Chars.Count(), Crypt.OutputBlockSize) == 0)
{
Length = Chars.Count();
}
else
{
int a = Mod(16, 16);
int L = Chars.Count();
while (Mod(L, Crypt.OutputBlockSize) != 0)
{
L += 1;
}
Length = L;
}
byte[] Input = getChars();
byte[] Output = (byte[])Array.CreateInstance(Bit.GetType(), Length);
Crypt.TransformBlock(Input, 0, Crypt.InputBlockSize, Output, 0);
this.EncryptedText = Output;
OutputBox.Text = ConvertBytesToString(Output);
KeyBox.Text = ConvertBytesToString(cry.Key);
}
private string ConvertBytesToString(byte[] Bytes)
{
char[] Chars = UnicodeEncoding.UTF7.GetChars(Bytes);
string Output = String.Empty;
for (int i = 0; i < Chars.Count(); i++)
{
Output += Chars[i];
}
return Output;
}
|