generateRandomKey() works but generateRandomString() doesn't

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), '+/', '_-');

Try with [color="#28353D"][font="Menlo, Monaco, Consolas,"][/font][/color]


Yii::$app->getSecurity()->generateRandomString();

[color="#28353D"][font="Menlo, Monaco, Consolas,"][/font][/color]

That works too, but is it a bug, since it should work like that above, or?

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]