惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
Google Online Security Blog
Google Online Security Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Simon Willison's Weblog
Simon Willison's Weblog
T
Threat Research - Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
L
Lohrmann on Cybersecurity
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security
S
Schneier on Security
T
Tor Project blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
WordPress大学
WordPress大学
The Hacker News
The Hacker News
Hacker News - Newest:
Hacker News - Newest: "LLM"
罗磊的独立博客
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
C
Check Point Blog
Stack Overflow Blog
Stack Overflow Blog
Blog — PlanetScale
Blog — PlanetScale
雷峰网
雷峰网
S
Security @ Cisco Blogs
PCI Perspectives
PCI Perspectives
Spread Privacy
Spread Privacy
W
WeLiveSecurity
SecWiki News
SecWiki News
A
About on SuperTechFans
H
Help Net Security
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
爱范儿
爱范儿
S
Securelist
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
月光博客
月光博客
Jina AI
Jina AI
博客园 - 叶小钗
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
Recent Announcements
Recent Announcements
S
Secure Thoughts
The Cloudflare Blog
美团技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - N/A2011

Managing Hierarchical Data in MySQL php soapclient with wsse 转贴 MySQL Multiple Result Procs in PHP 转贴 jQuery Datepicker by Example 转贴 Using MySQL Stored Procedures with PHP mysql/mysqli/pdo php generate pdf open office (java) ant + emma + junit Copy all files recursively from one folder to another RecursiveFileFinder 转贴: 怎样找第一份工作 PerformanceCounter in .net Trace in .net Logger in .net 转贴: 傅立叶级数(Fourier Series) 推导 CAS in .net Access Control List in .net User and Data Security in .net Unmanaged code in .net
Encrypting and Decrypting in .net
N/A2011 · 2009-05-19 · via 博客园 - N/A2011

VB.NET:

Imports System.Security.Cryptography
Imports System.IO
Imports System.TextModule Module1Sub Main()
        
Dim inFileName As String = "C:\in.txt"
        
Dim outFileName As String = "C:\out.txt"
        
Dim password As String = "Joey"
        
Dim salt As Byte() = Encoding.Unicode.GetBytes("Salt adds to left spaces")
        
Dim key As New Rfc2898DeriveBytes(password, salt)
        
Dim rm As New RijndaelManaged()
        rm.Key 
= key.GetBytes(rm.KeySize / 8)
        rm.IV 
= key.GetBytes(rm.BlockSize / 8)
        
Dim inFile As New FileStream(inFileName, FileMode.Open, FileAccess.Read)
        
Dim data(inFile.Length - 1As Byte
        inFile.Read(data, 
0, data.Length)
        
Dim encryptor As ICryptoTransform = rm.CreateEncryptor
        
Dim outFile As New FileStream(outFileName, FileMode.OpenOrCreate, FileAccess.Write)
        
Dim stream As New CryptoStream(outFile, encryptor, CryptoStreamMode.Write)
        stream.Write(data, 
0, data.Length)
        stream.Close()
        outFile.Close()
        inFile.Close()
    
End SubEnd Module

C#:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;namespace EncryptingAndDecryptingCS
{
    
class Program
    {
        
static void Main(string[] args)
        {
            
string inFileName = @"C:\in.txt";
            
string outFileName = @"C:\out.txt";
            
string password = "Joey";
            
byte[] salt = Encoding.Unicode.GetBytes("Salt adds to left spaces");
            Rfc2898DeriveBytes key 
= new Rfc2898DeriveBytes(password, salt);
            RijndaelManaged rm 
= new RijndaelManaged();
            rm.Key 
= key.GetBytes(rm.KeySize / 8);
            rm.IV 
= key.GetBytes(rm.BlockSize / 8);
            FileStream inFile 
= new FileStream(inFileName, FileMode.Open, FileAccess.Read);
            
byte[] data = new byte[inFile.Length];
            inFile.Read(data, 
0, data.Length);
            ICryptoTransform encryptor 
= rm.CreateEncryptor();
            FileStream outFile 
= new FileStream(outFileName, FileMode.OpenOrCreate, FileAccess.Write);
            CryptoStream stream 
= new CryptoStream(outFile, encryptor, CryptoStreamMode.Write);
            stream.Write(data, 
0, data.Length);
            stream.Close();
            outFile.Close();
            inFile.Close();
        }
    }
}