Vulisha
(Vulisha)
January 12, 2016, 11:02pm
1
Hello, it is me again, but this time i don’t think it is so much my fault.
So the problem is when I type
echo Security::generateRandomKey(32);
all works great, but I get loads of giberish signs and I want letters and numbers
when I type
echo Security::generateRandomString(32);
I get: Calling unknown method: yii\web\View::generateRandomKey()
why? o.O
http://www.yiiframework.com/doc-2.0/yii-base-security.html#generateRandomKey()-detail
I fixed it for my self, but I am not sure is it a bug or did I do something wrong.
Here is solution from securiry that I used:
strtr(substr(base64_encode(Security::generateRandomKey(32)), 0, 32), '+/', '_-');
mdomba
(Maurizio Domba Cerin)
January 13, 2016, 9:17am
2
Try with [color="#28353D "][font="Menlo, Monaco, Consolas,"][/font][/color]
Yii::$app->getSecurity()->generateRandomString();
[color="#28353D "][font="Menlo, Monaco, Consolas,"][/font][/color]
Vulisha
(Vulisha)
January 13, 2016, 9:21pm
3
That works too, but is it a bug, since it should work like that above, or?
mdomba
(Maurizio Domba Cerin)
January 13, 2016, 10:03pm
4
generateRandomString() is not a static method so you should not call it with [color=#660066][size=2]Security[/size][/color][color=#666600][size=2]::[/size][/color][size=2]generateRandomString[/size][color=#666600]size=2 [/size][/color]