EX-5 4 a2118821zex-5.htm EXHIBIT 5
QuickLinks -- Click here to rapidly navigate through this document


EXHIBIT 5

September 19, 2003

CompuDyne Corporation
7249 National Drive
Hanover, Maryland 21706

    Re:
    Registration Statement on Form S-2 for CompuDyne Corporation

Ladies and Gentlemen:

        We have acted as counsel to CompuDyne Corporation, a Nevada corporation (the "Company"), and are rendering this opinion in connection with the filing of a Registration Statement on Form S-2 (the "Registration Statement") by the Company with the Securities and Exchange Commission under the Securities Act of 1933, as amended, relating to the registration by the Company of (i) $28,750,000 principal amount of its Convertible Subordinated Notes due 2010 (the "Notes") and (ii) an indeterminate number of shares of the Company's common stock, par value $0.75 share (the "Common Stock"), issuable upon conversion of the Notes (the "Conversion Shares"). The Notes will be issued under an Indenture (the "Indenture") by and between the Company and Wachovia Bank of Delaware, National Association, as Trustee (the "Trustee").

        We have examined originals or copies, certified or otherwise identified to our satisfaction, of (i) the Registration Statement and all exhibits thereto, (ii) the Articles of Incorporation, as amended, of the Company (the "Articles"), (iii) the Indenture, and (iv) the form of the Notes. We have also examined such corporate records and other agreements, documents and instruments, and such certificates or comparable documents of public officials and officers and representatives of the Company, and have made such inquiries of such officers and representatives and have considered such matters of law as we have deemed appropriate as the basis for the opinions hereinafter set forth, including the Company's Bylaws, certain resolutions adopted by the Board of Directors of the Company relating to the issuance of the Notes and the Conversion Shares and statements from certain officers of the Company.

        In delivering this opinion, we have assumed the genuineness of all signatures, the legal capacity of natural persons, the authenticity of all documents submitted to us as originals, the conformity to originals of all documents submitted to us as certified, photostatic or conformed copies, the authenticity of originals of all such latter documents, and the accuracy and completeness of all records, information and statements submitted to us by officers and representatives of the Company. In making our examination of documents executed by parties other than the Company, we have assumed that such parties had the power, corporate or other, to enter into and perform all obligations thereunder and have also assumed the due authorization of all requisite action, corporate or other, and execution and delivery by such parties of such documents and the validity and binding effect thereof with respect to such parties.

        The opinions expressed below are based on the assumption that the Registration Statement will become effective and that the Indenture will be qualified in accordance with the Trust Indenture Act of 1939, as amended.

        Based upon and subject to the limitations, qualifications, exceptions and assumptions set forth herein, we are of the opinion that:

    1.
    When the Notes shall have been issued, executed, authenticated and delivered in accordance with the terms of the Indenture, and delivered in accordance with the Registration Statement, and assuming no change in the law from the date of this opinion, the Notes will be legally issued and binding obligations of the Company.

    2.
    When the Conversion Shares shall have been issued and delivered upon the conversion of the Notes in accordance with the terms of the Indenture, the Conversion Shares will be validly issued, fully paid and nonassessable.

        We express no opinion as to the law of any jurisdictions other than the federal law of the United States of America and the law of the Commonwealth of Pennsylvania.

        We hereby consent to the sole use of this opinion as an exhibit to the Registration Statement and to the use of our name under the heading "Legal Matters" in the Prospectus included therein. This opinion is not to be used, circulated, quoted, referred to or relied upon by any other person or for any other purpose without our prior written consent.

    Very truly yours,
     
    /s/ Ballard Spahr Andrews & Ingersoll, LLP



QuickLinks