我今天正在工作,然后我有了这个想法。我想制作一个采用纯文本的脚本,然后使用 T9 模式对其进行加密以用于手机上的 SMS 消息。
纯文本:你好
结果:4433555555666
所以我创建了一些这样的类:
<?php
class decoder {
public $keys = array(
'2' => 'abc',
'3'=> 'def',
'4'=> 'ghi',
'5'=> 'jkl',
'6'=> 'mno',
'7'=> 'pqrs',
'8'=> 'tuv',
'9'=> 'wxyz',
'0'=> ' '
);
function key($string) {
// store every character from the string into an array
$str = str_split($string);
}
}
$deco = new decoder;
echo $deco->key('hello');
?>
问题是我需要一些算法和行来说明如何将给定纯文本中的每个字符与键数组进行比较,然后在匹配时返回键号。