从 Delphi XE 访问 Delphi Prism 类库

发布于 2024-11-10 07:30:11 字数 1345 浏览 3 评论 0原文

我需要在 Delphi XE 中访问这个 Delphi Prism 类库中的方法“Auth”:

    namespace ClassLibrary1;

    interface

    uses
      System,
      System.IO,
      System.Security.Cryptography,
      System.Runtime.InteropServices,
      System.Text;

    type
      ConsoleApp = public class
      private
        class method hashMe(input: string): string;
        class method Encrypt(clearText: string; Password: string; Salt: array of byte; iteration: Integer): string;
        class method Encrypt(clearData: array of byte; Key: array of byte; IV: array of byte): array of byte;
        class method Encrypt(clearData: array of byte; Password: string; Salt: array of byte; iteration: integer): array of byte;
        class method Decrypt(cipherText: string; Password: string; Salt: array of byte; iterations: Integer): string;
        class method Decrypt(cipherData: array of byte; Password: string; Salt: array of byte; iterations: integer): array of byte;
        class method Decrypt(cipherData: array of byte; Key: array of byte; IV: array of byte): array of byte;
      protected
      public
        [UnmanagedExport('Auth')]
        class method Auth(userName: String; userPassword: String): String;
      end;

    implementation
[...]

使用 CrossTalk 非常容易,但 CrossTalk 非常昂贵,并且此代码适用于宠物项目。有什么简单的方法可以做到这一点吗?

TIA

I need to access in Delphi XE the method "Auth" from this Delphi Prism class library:

    namespace ClassLibrary1;

    interface

    uses
      System,
      System.IO,
      System.Security.Cryptography,
      System.Runtime.InteropServices,
      System.Text;

    type
      ConsoleApp = public class
      private
        class method hashMe(input: string): string;
        class method Encrypt(clearText: string; Password: string; Salt: array of byte; iteration: Integer): string;
        class method Encrypt(clearData: array of byte; Key: array of byte; IV: array of byte): array of byte;
        class method Encrypt(clearData: array of byte; Password: string; Salt: array of byte; iteration: integer): array of byte;
        class method Decrypt(cipherText: string; Password: string; Salt: array of byte; iterations: Integer): string;
        class method Decrypt(cipherData: array of byte; Password: string; Salt: array of byte; iterations: integer): array of byte;
        class method Decrypt(cipherData: array of byte; Key: array of byte; IV: array of byte): array of byte;
      protected
      public
        [UnmanagedExport('Auth')]
        class method Auth(userName: String; userPassword: String): String;
      end;

    implementation
[...]

This is very easy with CrossTalk, but CrossTalk is very expensive and this code is for a pet project. Any easy way to do this?

TIA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滥情空心 2024-11-17 07:30:11
function Auth(userName: PAnsiChar; userPassword: PAnsiChar): PAnsiChar; stdcall; external 'ClassLibrary1.dll' 

但在非托管/win32 代码中返回 PAnsiChar 并不是一个好主意。谁来释放绳子?

function Auth(userName: PAnsiChar; userPassword: PAnsiChar): PAnsiChar; stdcall; external 'ClassLibrary1.dll' 

But returning a PAnsiChar is not really a good idea in unmanaged/win32 code. Who is going to free the string?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文