目前,我有一个单词表 (~250k),我希望能够检测用户的 [新] P/W 是否包含表中定义的零个、一个或多个字典单词。我认为下面的比较会发送一条错误消息,其中只有 1 个字典单词,但示例 P/W 字符串(至少有 4 个单词,不包括 Be-My)“ThisWillBeMyPassPhrase2!1!”仍然被抓住。任何想法如何解决这个问题?
''' 打开 word_list; 环形 将 word_list 提取到 word_rec 中; 当 word_list%notfound 时退出;
if instr(nls_lower(password),nls_lower(word_rec.word)) = 1 then
raise_application_error(-20003, 'New password should have only ONE word or be a Passphrase');
end if;
结束循环; '''
错误信息:ORA-20003:新密码应该只有一个词或者是密码短语 28003. 00000 - “指定密码的密码验证失败” *原因:新密码没有达到必要的复杂度
答案 0 :(得分:0)
您当前的伪代码:
for i := 1 to dictionary_size do
if dictionary_word(i) is in candidate_password exactly 1 time then
stop the "if" and the "for" and raise app error;
end if;
end for;
它应该是:
counter := 0;
for i := 1 to dictionary_size do
if dictionary_word(i) is in candidate_password exactly 1 time then
counter := counter + 1;
end if;
end for;
if counter = 1 then
raise app error;
end if;
答案 1 :(得分:0)
通过像这样循环来对行集进行操作不是一个好主意。逐行是缓慢的。最好完全在 SQL 中一步完成。类似的东西:
select count(*) from (
select dt.word
from dictionary_table dt
where instr( lower( dt.word ), lower( password )) > 0
fetch first 2 rows only
)
存在 fetch first 2 rows only
是因为您只关心是否存在密码短语,而不关心其中是否有 2 或 7 个单词。因此,一旦您找到两个匹配的词,您就知道您有一个密码短语并且可以停止。