{"action":"created","issue":{"url":"https://api.github.com/repos/marcelocantos/bcrypt-for-delphi/issues/6","labels_url":"https://api.github.com/repos/marcelocantos/bcrypt-for-delphi/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/marcelocantos/bcrypt-for-delphi/issues/6/comments","events_url":"https://api.github.com/repos/marcelocantos/bcrypt-for-delphi/issues/6/events","html_url":"https://github.com/marcelocantos/bcrypt-for-delphi/issues/6","id":62687574,"number":6,"title":"Cardinal/Integer Bug in EksBlowfishSetup","user":{"login":"mminuss","id":11538553,"avatar_url":"https://avatars.githubusercontent.com/u/11538553?v=3","gravatar_id":"","url":"https://api.github.com/users/mminuss","html_url":"https://github.com/mminuss","followers_url":"https://api.github.com/users/mminuss/followers","following_url":"https://api.github.com/users/mminuss/following{/other_user}","gists_url":"https://api.github.com/users/mminuss/gists{/gist_id}","starred_url":"https://api.github.com/users/mminuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mminuss/subscriptions","organizations_url":"https://api.github.com/users/mminuss/orgs","repos_url":"https://api.github.com/users/mminuss/repos","events_url":"https://api.github.com/users/mminuss/events{/privacy}","received_events_url":"https://api.github.com/users/mminuss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-18T12:59:11Z","updated_at":"2015-03-18T13:27:28Z","closed_at":null,"body":"I've compiled this code with Delphi XE7.\r\n\r\nIf I understood the BCrypt algorithm correctly, then this would take forever...\r\n\r\n```delphi\r\nHash := TBCrypt.HashPassword('password', 31);\r\n```\r\n\r\nBut it finished immediately. I think there might be a bug in EksBlowfishSetup. Or in my compiler...\r\n\r\n```delphi\r\nclass function TBCrypt.EksBlowfishSetup(const Cost: Integer; salt, key: array of Byte): TBlowfishData;\r\nvar\r\n  rounds: Cardinal; //rounds = 2^cost\r\n  i: Integer;\r\nbegin\r\n  // ...\r\n  rounds := 1 shl cost;\r\n\r\n  for i := 1 to rounds do\r\n  begin\r\n    // ...\r\n  end;\r\nend;\r\n```\r\nI've set a break point inside the for-loop, but with cost factor 31 (which is the highest possible value), I don't get there.\r\n\r\n`1 shl 31` will be `2147483648` as a `Cardinal` but  -1 if it is an `Integer`. `rounds` is declared as `Cardinal` but the code inside the loop doesn't run.\r\n\r\nIs this my compiler or can this be easily fixed?"},"comment":{"url":"https://api.github.com/repos/marcelocantos/bcrypt-for-delphi/issues/comments/82969931","html_url":"https://github.com/marcelocantos/bcrypt-for-delphi/issues/6#issuecomment-82969931","issue_url":"https://api.github.com/repos/marcelocantos/bcrypt-for-delphi/issues/6","id":82969931,"user":{"login":"mminuss","id":11538553,"avatar_url":"https://avatars.githubusercontent.com/u/11538553?v=3","gravatar_id":"","url":"https://api.github.com/users/mminuss","html_url":"https://github.com/mminuss","followers_url":"https://api.github.com/users/mminuss/followers","following_url":"https://api.github.com/users/mminuss/following{/other_user}","gists_url":"https://api.github.com/users/mminuss/gists{/gist_id}","starred_url":"https://api.github.com/users/mminuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mminuss/subscriptions","organizations_url":"https://api.github.com/users/mminuss/orgs","repos_url":"https://api.github.com/users/mminuss/repos","events_url":"https://api.github.com/users/mminuss/events{/privacy}","received_events_url":"https://api.github.com/users/mminuss/received_events","type":"User","site_admin":false},"created_at":"2015-03-18T13:27:28Z","updated_at":"2015-03-18T13:27:28Z","body":"I've looked at the generated assembly code. It seems to be a compiler bug.\r\n\r\nCan somebody test this in other Delphi versions?\r\n"}}