2016-04-02 6 views
0

文字列を取り、文字列の各値を10進ASCII値に変換しようとしています。私は最初に文字列を[]バイト型に変換し、[]バイトの各要素を取り出して10進ASCII値に変換したいと考えています。文字列を含む[]バイトを10進数値に変換する

myArray := []byte(password) // convert string into []byte type 
NumArray := [len(password)]int // create second []int type to store the converted []byte elements 
for i := 0; i < len(myArray); i++{ 
           /* I need some help to convert each element in myArray into ASCII decimal value and then store it into 
            NumArray. 
           */ 
fmt.Printf("%d\n", myArray[i]) //prints out what the converted values should be 
fmt.Print(NumArray[i]) //prints out the stored converted value for comparison 
} 

編集:ここに私のコードがある文字列は、パスワードことになっているので、あなたがこのようintbyteをキャストすることができ、任意の値

+0

をだからあなたをあなたがしていることを教えてくれました。あなたに質問がありますか? –

答えて

0

を含めることができます、

NumArray[i] = int(myArray[i]) 
関連する問題