Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Text;
- using System.Threading.Tasks;
- namespace Vjezba05
- {
- class Program
- {
- static byte[] bytes; // = ASCIIEncoding.ASCII.GetBytes("ZeroCool");
- static void Main(string[] args)
- {
- string a = "";
- bytes = ASCIIEncoding.ASCII.GetBytes(args[1]);
- Console.WriteLine(Encrypt(args[0]));
- Console.ReadKey();
- }
- public static string Encrypt(string originalString)
- {
- if (String.IsNullOrEmpty(originalString))
- {
- throw new ArgumentNullException
- ("The string which needs to be encrypted can not be null.");
- }
- DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
- MemoryStream memoryStream = new MemoryStream();
- CryptoStream cryptoStream = new CryptoStream(memoryStream,
- cryptoProvider.CreateEncryptor(bytes, bytes), CryptoStreamMode.Write);
- StreamWriter writer = new StreamWriter(cryptoStream);
- writer.Write(originalString);
- writer.Flush();
- cryptoStream.FlushFinalBlock();
- writer.Flush();
- return Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement