2009年9月16日 星期三

.NET 如何加密一字串,只讓執行加密的電腦才能解密。

就這樣:
ProtectedData 是 .NET 提供的加密類別,透過此類別加密的資料,只要執行加密的電腦才能解密。

下列程式碼所用到的 System.Security 組件要自行加入參考中。

public static string Protected(string password)

{

if (string.IsNullOrEmpty(password)) return string.Empty;

byte[] plain = Encoding.UTF8.GetBytes(password);

string key = "key";

byte[] cipher = ProtectedData.Protect(plain,

Encoding.UTF8.GetBytes(key),

DataProtectionScope.CurrentUser);

return Convert.ToBase64String(cipher);

}

public static string UnProtected(string base64String)

{

if (string.IsNullOrEmpty(base64String)) return string.Empty;

string key = "key";

byte[] cipher = Convert.FromBase64String(base64String);

byte[] plain = ProtectedData.Unprotect(cipher,

Encoding.UTF8.GetBytes(key),

DataProtectionScope.CurrentUser);

return Encoding.UTF8.GetString(plain);

}


2009年9月10日 星期四

在 Windows 7 上安裝 BootCamp 2.1 (x64) 的方法

我的是 MacBook,一般的 Mac 不知道適用嗎...

1.先把語言改成英文的。
2.執行 BootCamp 2.1 升級程式。

無言的第三行...

2009年9月4日 星期五

讀取 Postgresql 資料 Schema 方法

查詢主機上有哪些資料庫:
SELECT datname FROM pg_database

查詢資料庫有哪些資料表:
SELECT * FROM information_schema.tables

查詢資料庫有哪些資料欄位:
SELECT * FROM information_schema.columns

查詢資料庫的大小:
select pg_database_size('ischool_junior_cgjh_hc')

2009年9月3日 星期四

重設 Postgresql 的 Sequence 方法

這個方法是將 Sequence 設成使用此 Sequence 的資料表 id 最大值。

SELECT setval('dal_log_id_seq', max(id)) FROM student;

2009年9月1日 星期二

使用 Sandcastle Help File Builder 製作 VS.NET 的 HELP 文件

http://itgroup.blueshop.com.tw/jeff377/blog?n=convew&i=3777