internal static void WritePasswordString(Stream destination, string value)
{
// Check if value is null
if (string.IsNullOrEmpty(value))
{
// There's nothing to write
return;
}
// Convert
byte[] byteString = Encoding.Unicode.GetBytes(value);
// Perform password decryption
for (int i = 0; i < byteString.Length; i++)
{
// Swap 4 high bits with 4 low bits
byteString[i] = (byte)(((byteString[i] & 0xf0) >> 4) | ((byteString[i] & 0xf) << 4));
// XOR
byteString[i] ^= 0xA5;
}
// Write into a the stream
destination.Write(byteString, 0, byteString.Length);
}