暗号方式の取得
- java.security.Securityクラスにより取得できる
- 聞いたことのない暗号方式も取得できる
package net.kuttya.cryptalgorithmprinter;
import java.security.Security;
import java.util.Set;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class CryptAlgorithmPrinterActivity extends Activity {
private TextView textAlgorithm;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// 表示領域
textAlgorithm = (TextView)findViewById(R.id.text_algorithm);
}
public void clickEventPrint(View v) {
// 使用できる暗号方式を取得
Set<String> algorithms = Security.getAlgorithms("Cipher");
textAlgorithm.setText("");
for(String algorithm:algorithms) {
textAlgorithm.append(algorithm + "\n");
}
}
}
- 直接関係しないがレイアウトは次の通り
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/print"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="clickEventPrint"
android:text="暗号方式表示" />
<ScrollView
android:id="@+id/scroll_algorithm"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text_algorithm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</ScrollView>
</LinearLayout>
こんな感じで表示される。
AES、DES、RSAくらいしか聞いたことがない。
まあ、実際に使うのはAESかRSAだと思う。

0 件のコメント:
コメントを投稿